Significantly refactored code in #test_3_add_rule_types.