add longest segment functions and tests