Fixed problems

Fixed many problems of the mysql database class.
Improved tests