add some diagnosis functions, add some debug output to test