Added more complex functional tests and refactored tests DB