Added test. Fixed code.

I added a test and the whole thing broke. Fixed the bug.