Explicitly UTF-8-encode strings before DB insert

Change-Id: I59aac26ff8a648de9a4308e5299623884a3287b0
Database tests and test fixtures

This change abstracts some test helpers out of SchemaTestCase and adds a
few test helpers, making them available as mix-ins for
unittest.TestCase.

The database test mix-in tests database calls using an in-memory sqlite
database.

Change-Id: I88d27c381213f4bafa04cce24c5c04e17891e767