(Sub)module not found in test when using dune

From that other thread:

I do have a lib/dune file that says (library (name mylib)), so that would mean the module in lib/mylib.ml would be available as Mylib.Mylib and the module in lib/mymod.ml would be available as Mylib.Mymod. But that isn’t the case, i.e. this fails:

let _ = assert (Mylib.Mylib.one = 1)
let _ = assert (Mylib.Mymod.two = 2)

Instead, if I change (library (name mylib)) to (library (name foo)) (and modify test/dune accordingly), then these are suddenly available as Foo.Mylib and Foo.Mymod, i.e. this works:

let _ = assert (Foo.Mylib.one = 1)
let _ = assert (Foo.Mymod.two = 2)

Why does the first fail and the second work?