refactoring & improved test coverage for isSameFile