Added a state-score cache and more tests