Fix incorrect detection of presence of Promise