Fix bit operators with BitArrays and add tests