big refactor .

introduce messageDispatcher to work with NewMessageListener
decouple batch save logic to UnsavedMessageQueue. use IMessageCache
interface
add assert
refactor some test