I think an important thing is what God says as he banishes Adam and Eve.
"Behold, the man is become as one of us, to know good and evil: and now, lest he put forth his hand, and take also of the tree of life, and eat, and live forever" (Genesis 3:22).
God explicitly states that their expulsion is to prevent Adam and Eve from becoming immortal, and not as punishment for going against his word. Whether this is his true purpose, I have no idea, but throughout the Genesis, like striking down the Tower of Babel, God tries to prevent man from achieving immortality. Therefore, I think that the fruit "gave them something God didn't want them to have," as you said, and was not placed as a test. Of course, there are many other interpretations, and I'm not a scholar of the Bible. Regarding free will, I think that man had free will regardless if the fruit was a test. After all, God had only banned the Tree of Knowledge of Good and Evil, and allowed Adam and Eve to do whatever else they wanted. Unless I'm misinterpreting the meaning of "free will"?