added support for states. Reorganized tests. Changed context that rule functions are called under so that they can call this.state('newState')
added test for states