added debug output to test cases
simplified code
removed unused flags