improvements + tab fix

as per comment

fixed a bug: by using "window.location" it wasn't working unless a window was present. I've used a tabs.query to load the URL into the current tab, and moved the URL open logic into another function