Implementation of RuleCPD and tests