DROOLS-494: refactoring some classes to avoid name clashes. Adding test cases. Fixing bugs.