Fixed bugs in TestCase
Added tests