bug fixing for test.cpp