Fix some issues raise by coverity in the tests.