add tests and refactor url creation