Refactoring + unit test for method getUrlWithoutPath