move messaging methods to separate file, add tests