Well, the work wasn't necessarily for a commercial purpose on its own, but the combination of the work and the contract made it commercial, and this is the risk you run with any sort of "fanfiction" like this.
You have a lot of latitude to produce it for fun, but if you want to actually go to sell it into the same market as the original work, then there are problems.