added cache and tests for it