Finished the tests, and fixed the broken code: yep, it was broken.