Refactored test code from pipeif-semaphore branch actually useful