I just ran the test on a newer machine with macOS 15.5 and everything worked. This must be a strange Apple bug which seems to be fixed in the latest versions of the OS.