implemented message handler and tests