Minor changes in tests and error handling