Backport test_timeout

The code to plan and commit relies on the test itself timing out
eventually. This brings back the change to have a timeout for the test
itself.