Use named function and invoke it from background.js

The self-executing anonymous function worked fine in our Chrome
Extension but it was hard to test as we couldn't deterministically
invoke it.

By naming the function and invoking it from within background.js, we
can continue to provide the existing Chrome Extension behaviour _and_
make it possible to test.