The code from the test case is using an optional association whilst the issue seems to be about a non-optional association? I'd expect the results to be different for a non-optional association.