Clean up pep8 and pylint violations

Also fixes failing Python unit tests
Merge pull request #5905 from edx/renzo/pep8-pylint-cleanup

Clean up pep8 and pylint violations