minor cleanup and fix unittest