Split service methods from MessagesController

Removed business logic from MessagesController for testing purposes.
Also added necessary libs for unit testing.