Tests are implemented
Small sql changes