Added a pending test for invalidating the cache.
Refactored promises slightly.