Fixed event-based testing with conditional variable instead of semaphore.