refactored path manipulation; added some code generation for test