Reorganized unit tests

Moved functions used both by frontend and sqlite
backend tests to separate file.