Ispn 4599

Contains fixes for:
 - https://issues.jboss.org/browse/ISPN-2727
 - https://issues.jboss.org/browse/ISPN-4048
 - https://issues.jboss.org/browse/ISPN-4165
 - https://issues.jboss.org/browse/ISPN-4186
 - https://issues.jboss.org/browse/ISPN-4599

(Ultimately all caused by ISPN-4599)
true, I did in fact copy them from a similar thing in the Infinispan Directory module. In hurry I didn't find a helper in Infinispan core, should I create one?