Move the function definitions around so they are easier to find by alpha
Add in our rule validation and tests