Improve base_url support

Use URLObject for relative URL resolution. Also, tests!