Fix environment detection in require.js environment because some umd place

typeof require === "function" && typeof exports === "object" && typeof module === "object"

check before

typeof define === "function" && define.amd

Test added.