Test cleanup.
Adds initial ternary implementation.
Adds more ternary support.