Fixed random crashes when trying to free a NULL pointer. Added a Bash script that can be used to run all the tests and print out which one fails