Fixed alert test logic to wait for errors correctly.
Fixed alert test to check for error events correctly.