Passing unit tests

Some unit tests were wrong, and code was wrong. Together, we got there.