Upgraded materia to AMD using RequireJS, added modules, fixed unit tests