The rulestest was really deeply nested - this factors that repetitious, deeply nested code out into repetitious, less-nested code. I still need to work on getting rid of the repetition.