I had 2 alpha channels plus the 3 RGB channels (but the never get logged on my side – don’t know why).
Here are the results from your inputs:
I tested it on a completely different machine (again macOS, but 10.15.7).
But what is so strange to me is that I used the same logic of this code in ExtendScript with no problems …