refactored, unit testing, buffer-to-messages