Tests fixes and flake8 styling.