Cleaned tests file to correct all pyflakes and pep8 errors

Agreed with perhaps the exception of the active Django refactor and related tests that still need fixing :)