Fixes an issue with timouts and refactors some test code.