Database cleanup/unittests enablement v1

What started as fixing database unittests, evolved to the following decisions:

* Drop all necessary hacks to support SQLite on the unittests run
* Only worry about the database that we actually support on production: MySQL
* Allow unittests to run on MySQL in a safe and straightforward way

Those decisions are coded on this PR, together with large cleanups, a couple of fixes and improvements that popped up during the development.

My favorite cleanup is that the database_legacy is almost gone (really!) and will be gone on the v2 of this PR.

This first version is intended for community awareness only, and it's not supposed to me merged.