Fix the tests not to use '127.0.0.1' and 'localhost' interchangeably.
More specifically, since tests bind specifically to 127.0.0.1, connect
to that address as well; using 'localhost' can resolve to IPv6 address
which can cause issues -- for example, if the matching port happens to
be used by some other process, the tests hang forever waiting for
the client to connect.
While technically the case of randomly selected IPv4 port being taken
on IPv6 loopback is not very likely, NetBSD happens to be suffering from
some weird kernel issue where connection to that port succeeds
nevertheless. Until we can really figure out what goes wrong there,
this saves us from the tests hanging randomly.