Update cache logic, add test, tests passing