fix connection error handling for tests