Refactor duplicate db unit test code into base

Change-Id: Ie8f6e72ebf3c37472291d326e04825d03c76265b
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>