Make sure that is_entity() does not throw.