refactor wait_for_expected_title a bit