refactoring controllers and testing messages index