cleanup and better tests