add codeBits, encode and some additional tests