Make code PEP-8 compliant and refactor more test utils