Revert "Removed pointless tests for whether ctx was NULL or not."

This reverts commit ba06bfde7cd7bc7788d9e2e22c5e44f032d37a32.