added some tests.  fixed some bugs the tests showed me.