Better connection handling in tests and reset timeouts after timeout test