added test for timeout
cleanups and added test case.