Refactored getEarliestText() so that it's easier to test.