Bkup before refactor
Replaced chdir execution
Repaired test
Refactored variable usage