Bug 826065: database interface rewrite

This moves all of the database code into purpose-specific classes, then
combines those all in a nice facade.  The current DB object is passed
around, rather than being a global; this
 * presents minimal difficulty
 * ensures that only code that should be talking to the DB does
 * ensures that a given server instance shares exactly one instance of
   the DB interface
Bug 844363: better tests for mozpool

Because 80% test coverage is good enough for anyone.
store current and next image separately in the devices table
Generalize async operations, use that in the BMM API

This also adds support for asynchronous HTTP requests, and uses those
from the request machine.
AsyncMixin for tests - probably unnecessary?
WIP - device_request stuff

TODO:
 - devicemachine makes requests to mozpool on all terminal states