Split cache to a separate class. Add tests for said class