Small fixes on cache management + new tests