Fix MAGN-657; MAGN-664

Defect fixing and add test cases.