test: Use a pipe to synchronise wait_for_xxx events
The condition variable thing clearly not working for us.