Fix tests and flake8

- Fixed tests
- Created mocks for future tests
- Fixed flake8