actually write some tests... and fix a bug... revealed by the tests :P