cleanups of debugging.
catch case where sql insert fails.
 Improvements to tests.