Added optional AMD support. Unit tests upated for AMD with RequireJS