added test and improved msgbuffer