improve interfaces for sendMessage and add some tests