Fixing bugs in tests