Fix a bug with empty context

Problemo: Exception thrown if empty context is passed
Fix: Make sure context key is not created if context variable is None
Unit test added.
Closes-Bug: #1286373
Change-Id: I8ab5691fd34ab98c6fd99fbd35281b5179bb0dd5
Merge "Fix a bug with empty context"