Added some globals to prevent unnecessary warnings
Refactoring of services and controllers with karma tests