Add a test of the cubestate optimization and simplify it. Changed it to be
O(N) vs. worst case O(N*N) with the previous approach.