Refactored duplicate test code. Pylint cleanup.