Improve the bruteforce test (and fix the bugs it revealed).