Pulls db access out for better testing

Adds a new DB API layer can easily be mocked out for No DB testing of
the components of Quark. Also refactors the IPAM tests to utilize the
new API.