Correct all warnings and bugs in tests