tests and sql fix