improve some SQL issues and run rspec