Fixes NullPointerException when the species does not exist and adds a test for this issue.
Closes #17606
test