re-work db

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
update tests

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>