Run some APIv1 tests on different backends

This is a first change towards implementing bug #1131638. It clears a lot of
stuff in the various DB mocking stuff, and I plan to do more after.

In the same process, this implements a unit test and a fix for bug #1138137

Change-Id: I36a6741393455c764913e0388d73d834db06da8c
Signed-off-by: Julien Danjou <julien@danjou.info>
Merge "Run some APIv1 tests on different backends"