some minor fixes and lots of tests for testcase