cleanup and add a few tests