Add specs and fix logic

Prior to this there were cases where the timeout did not behave as expected. All tests now pass.