Fix bit vector

Should fix the problems you found with the BitVector class, and added some tests.