Add a bunch of tests for rules.
more tests
Fix more stuff.