Added a unit test for the condense script, fixed some bugs it reveals