Add some tests for setting NULL to deallocated pointers releated to #842 and #833
mentioned in commit 424ce4ce