wait_closed method added; tests fixed to close connections in tearDown