Fix impotent test and refactor connection code a bit in conn_test.go