added many tests using Qtest;
fixed 2 bugs