PMO-2415: logic corrected and test case added