minor cleanups and lot's of new tests