used moq to speed up slow tests
refactored the code and the tests