Add a bunch of tests to struct and fix the bug they uncovered.