Shorten user agent.
Add messages to all exceptions.
Minor cleanups
Improve error handling in client and server.
Simplify tests with unittest.mock.patch.