Make sure pollUntil helper does not time out immediately

Also normalises the type of the returned error, which before had
been either 'Error' or 'ScriptTimeout' depending upon which part
of the system timed out first. Now it is always 'ScriptTimeout'.

Includes some basic tests that did not exist previously due to
time constraints. Untested code is broken code.

Fixes #1.