introduced prepareURL function with tests