Updated timeout code for Linux and OSX, and updated a test.