Improve testing framework

Since we have just moved to py.test, it is wise to use its fixtures to setup/teardown database in consistent manner. Patches from this pull-request implement most useful ones and update tests to use them. This makes tests more readable too, as it removes all the code duplication from setup/teardown.

This change have improved my test run-time from ~20s to ~10s.