Add -u, --url option (fixes #2), add tests, refactor everything