fix lang.exists() corner case and add unit tests, fixes #16291