Explicitly check status code after posting a new document

Also refactored the tests to make their intention clearer.