test connection refused error

This is not a good way to test a network failure, but I reckon it is slightly better than the previous test,
since it relies on a localhost IP and reserved port.
A better test would require to inject a `request` mock into the library, but this requires the new library to accept such injection