ensure correct encoding

ensure commands and arguments are encoded before being sent to the socket and decoded when revieved, also add tests