Bug 916718 - Fix condition to remove listener and unit test