Fix: factory should be called only one time depending on the environment

Small fix for browserify, in some cases old code caused a problem