Scotland-based cake makers Lees Foods and Thomas Tunnock have won a legal battle over the tax status of their Snowballs snacks.