Added setting of event on timeout and refactored tests.