Fixed an issue with caching, and added a couple of new tests