Fix bug in Study.GenerateId() and Form.GenerateId() which caused ErrNotFound to be returned by accident