moved timeout handler into a separate module, added some tests(ish)