Implemented error checking at a deeper level. test-p-bad.sh now runs correctly.