it would be great to add a test case that covers when len(bitsx) > len(bitsY) to cover your other while branch