Extract ByteUtils class and add test