Added a test function

Also some better timeout methods.