Move extractPath to extract in PathSpec, add tests