`getNextSegment` tests and implementation.