Moves database setup/teardown closer to its usage

The setup code needed third party Python modules that are not Python 3
compatible to be imported. This made it impossible to run any test under
Python 3 without doing a bit of sys.modules magic.

bp python3

Change-Id: Ife1af897018b95c9f22c5aa42cd9319a4182b58d
Merge "Moves database setup/teardown closer to its usage"