Added mocking and some tests