NPE caused by null safe dereferencing

Added the test to show null safe dereferencing bug