Fix unit test bug; Add test failure logging