daemonise worker threads so tests can be terminated with TERM signal

This is a rehash of pull request #1. The different issues are now in separate commits and the suggested changes incorporated