Adding timeout limit to PhpWorker

Some more tests were also written to ensure the worker does not run
infinitely.