Extract runningInBrowser to util