Split out URL parsing to enable testing, add tests