Improved testing for errors and unexpected messages.