Use class for test worker, and performs PID check in unit tests, #412