Converting bits to number was wrong.
Added automatic test for this.