Fixed LRUCache hangs.

This fixes a bug whereby the LRUCache could get stuck in limitCost(), never able to meet the maximum cost requirement because an item had been cached but not yet placed in the list.

The improved test cases both expose the hang (they never completed without this fix) and also perform better checking of the cost counting.
Merge pull request #297 from johnhaddon/lruCacheFix

Fixed LRUCache hangs.