add unittests for testcase and refactor testcase related implementation