fix bug 1074201 - refactor test base classes and introduce some more

- this also fixes various issues with tests that improve speed and performance
- includes plenty of stylistic changes like PEP8 updates
Merge pull request #2784 from jezdez/bug1074201

fix bug 1074201 - refactor test base classes and introduce some more