add cache tests and fix a few probs they uncovered