Fix DBReferenceError on MySQL and SQLite

It turns out the test was wrong as the error message used was not a good
one. Real world tests showed that, so I've updated the test and the code
to work.

Refactored tests to use real backends, fix error message for SQLite.

Co-Authored-By: Victor Sergeyev <vsergeyev@mirantis.com>

Change-Id: Ifa64478a9ac9ed0a3c317a8974615b770c85f313
Merge "Fix DBReferenceError on MySQL and SQLite"