unit testing. refactor runTestCases ctrl