refactored to use mocks for testing

refactored the tests to use mocks and refactored the main bot code
accordingly