#473 change sleep to wait for condition

Change time.sleep to wait_for_condition