Tighten up waiting on async code in tern.js

Issue #24