fix bug in unit test code

so that we correctly capture test results