Refactored getEarliestText some more to make it easier to test.