Added tests.
Bail if document is not defined.