Fix non-noneable KeyError, adding test case