Fix tests and PEP8