Add tests for caching framework (WIP)

For #837.