Test and fix for NH-3324
Add repro test for NH-3408
More correct fix based on collection mapping information
Refactoring of contributed code
Add more tests for NH-3408