Cleanup and minor bugfixing to testcases/the tap parser

- Plug leaks with regular expression objects.
- Fix a use-after-free in an edgecase after a program couldn't be executed.
- Use getegid() instead of getgroups()[0].
- Fix the try_parse_plan__insane testcase.