Change UMD definition

According to the [UMD-JS Github project](https://github.com/umdjs/umd) it is
better to first check for AMD and then for CommonJS. The reason being that
some build tools expose an exports object which could lead to a fall positive
for CommonJS.