fixed detach to not hang on session error, fixed the tests to include a timeout for connection teardown