Better implementaiton of wait_worker_done+performance tests