allow to register a callback to release items at destroy time

+ tests