Clean up the URI generation code

Fairly simple changes:

1. Add some unit tests
2. Ensure the URI generation code doesn't escape things it should not (so we can use third party QR image code)
3. Replace a large third party library with something smaller and with a simpler api