Bug fixes for tests