Add wait_for method to functional tests