Added a null check in the context util method.

Reviewer: HelenD