Chaining related changes

Also minor bug fix in rule test