fix tests and flake8