Corrected a couple issues, change a bit of things, implemented tests, ad...

...ded an abstractRule to prevent code duplication