Fix a bug in the script, and add test outputs