wrap the code to make it also compatible with AMD
make sure it pass the test
remove unused files
remove unnecessary line
Merge AMD compatibility (#185).