Bug fixes in tests