code clean up; added test case for checking recovery during broken connection