Corrected timing issue caused by setting the current document too early

The issue was manifesting itself by not having the tern server fully
operational when the document was being set