MDL-48063 behat: Fixed JS Exception

M is not created on all pages, like cron and
Steps which check for exported data. So we need
to ensure M is defined, before using it in
behat_hooks::wait_for_pending_js()