Fix NPE when connected entity doesn't exist
Merge pull request #152 from aweeraman/USERGRID-18

Fix and test for USERGRID-18