Added tests, fixed bitfield writing.