enhance test to fix Coverity issue CID 60867 : EC: Comparing incompatible types for equality
refactor code to fix CID 60865 : dereference null return value