corrected error handling in test.c