some cleanup and fix tests