fixed bug in valid bit calculation, lots more tests pass