Minor refactoring in waitForText methods