To get the impact/context of what the Apostle John is talking about we need to start with verse 1.Evidently false teachers who were harassing the churches with doctrines characteristic of the Gnostic heresy.
So when John says to "test the spirits" he is referring to people claiming to get their message from a supernatural source. Christians need to realize that not every spirit represents God. As far as I'm concerned there are too many "gullible" Christians out there. They need to test/try any prophet who claims to speak as the a mouthpiece for the Spirit of God.
We cannot be foolish enough to assume that all claimants truly have their in God because a large number of false prophets and antichrists were already in circulation according to 1 John 2:18. We should not deny that we can receive guidance from the Holy Spirit, just read John 16:13.
So how do we "test/try" the spirits? By knowing your Bible/the Word of God. This is what the Apostle Paul stated at Acts 17:11. "Now these were more nobleminded than those in Thessalonica, for they received the with great eagerness, EXAMINING THE SCRIPTURES DAILY, (WHY?) TO SEE WHETHER THESE THINGS WERE SO."
As a side note, many people fail to read the next verse 12, "Many of them therefore believed, along with a number of prominent Greek women and men." This is what happens when you study hard the word of God. You will get results, and remember our calling is other people.
Now, regarding 1 John 3:9? Christians are "NOT" sinless, we commit sins. The idea is that Christians will not make a "habit" of sinning. Like I said, Christians who are born again believers still commit sin. Why else would the Apostle John say the following at 1 John 1:8, "If we say that we have no sin, we are deceiving ourselves, and the truth is not in us." Or verse 10, "If we say that we have not sinned, we make Him a liar, and His word is not in us."
Moreover, 1 John 2:1,2, "My little children, I am writing these things to you that you may not sin. And if anyone sins, we have an Advocate with the Father, Jesus Christ the righteous. Verse 2, "and He Himself is the propitiation for our sins, and not for ours only, but also for those of the whole world." Let me close with this statement. "If you don't hate sin then there is something wrong with your Christianity."