Cleaned tests file to correct all pyflakes and pep8 errors

It might make more sense to declare these elsewhere and reference them in the `for`, rather than declaring them in the `for`.