added better handling for JS Singleton for browser and server implementations with tests. Also added better handling of attaching Builder to either window or exports for the browser or server respectively