tests fix and pep8 reformat