I would probably fold the need_test_connection into test_conection so you don't have to case on it here.