Fix inaccurate len_in_bits (issue #3) + test