Update isMessage function for usage with different library contexts.

If message object is created in different context than context of
the isMessage function, the function will return invalid result.