Refactor the PATH computation to be a bit more testable