daemonise worker threads so tests can be terminated with TERM signal (rehash)

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