Refactor stuff into utils module
Add tests for command messages