Split interface from implementation in Context class

This change would increase maintainability of the code and allow us to mock Context class in tests.