Fixes #15

Added test for #15, and fixed an issue with rule inheritance.