More error handling in tests, add debug mode for test running