Fixes #4286: Refactor code from Rule category repository

http://www.rudder-project.org/redmine/issues/4286