Fix writeBits()
Rewrite tests using hexadecimal numbers