Fix segfaults in add-on tests
Merge pull request #6151 from wmtan/FixSegfaults

Fix segfaults in add-on tests