Added a check for null and string data objects

Verified the data being sent to JSON.stringify when allow$properties is
set, was actually an object. Also added a test.