fixed some bugs in unit test