Refactor wait_for methods in ui_helpers for acceptance tests.