found a bug and improved testing routines.