Fixed small mishandling bugs in tests