Use explicit rather than implicit wait in tests

Hopefully, this will make some errors more apparent and provide a
more consistent run between environments.

In particular, the iframe switch has been failing in travis. Maybe
this will help.
Unused imports and pep8 in tests
Replace 'has_key()' with 'in'