Improve ShortenedUrl code

Some late comments from @grobie prompted this update, and gave me an opportunity to add tests, and everyone loves tests.