Allow loop to stop after wait() has been called
Add wait() test