more robust type checking in testcase.TestCase