Path utils with extra tests.

This is #287 with extra tests. I'm happy for it to be merged. :)