Fix undefined URL_BASE in background.js

Sieze an opportunity to move code out of the helpers.js.
Only 616 more lines to go.