Use table-driven tests
Add test for cache limit
Refactor cache implementation