fix a bug which may lead to memeory leak. add test report for improveing
accuracy later.