Improved logging for test function