better error control when dealing with ready state and errors in the callback

follow up after PR #53