Handle PathSegmenter edge cases and add test coverage