flake8 fixes and unit test fixes.