Refactored code to be simpler to understand
Fixed occasional timing error in Selenium webdriver
Fixed issue #2703
Merge pull request #2798 from jrief/fix-issue-2703

Fix issue 2703