Fixed some problems based on last working version

Added an sql script to make the tests over db easier