fixed failing tests and handling of exceptions