This should fix the hanging tests, and also make the testsuite more robust against hanging in future.