Amd define

Added unit tests, amd/commonjs/window module support