Extracted the module definitions to sp.js and fixed tests