better error handling and adding sleep to prevent intermittent travis mongodb error.