Correcting logic error in IE driver alert handling.

A slight logic error in the alert handling code was causing the alert
handling to not wait for the alert to be completely dismissed before
continuing. This was causing a race condition that could lead to crashes
when quitting the browser if certain types of alerts were active. Fixes
issue #5489.
Updating .NET Alerts tests.

Making test more robust by waiting for proper condition and adding test
for quitting browser with onBeforeUnload event handler in place.