Fix some bugs in  tests