Fixed path calculations and added a simple unit test for this