Added better error handling for bad connections in test