Extract the path resolution logic out of .register. Refactor paths handling in the test/env.js