[bug 766394] Test for generate_short_url.

Test runs and passes.
[bug 766394] Separated tests to own functions.

Also added custom exceptions.