NewDocumentFromResponse crashes when nil pointer is passed

NewDocumentFromResponse will crash when a nil pointer is passed in because the parameter is not being validated.

I added the check and a test for it.