Webtest

I get the prize for biggest PR yet!
- Fixed many uses of sleep
- Removed annoying boilerplate comments
- Moved boilerplate code into functions
- Migrated the remaining calls to open to use openCiviPage
- Spot checked and fixed a few failing tests
- Use more reliable ways to wait for things to load
- Lots of code cleanup