Fix nunit tests caused by null session
Merge pull request #2221 from Randy-Ma/unit_tests

Fix nunit tests caused by null session