I'm not sure how to write standalone tests for each of two changes here. If either one of these two fixes is missing, the test fill crash.