cleanup and fix tests