Refactor the module so that it can be loaded by loopback mobile template

/to @ritch 
/to @bajtos