Saying, Let [us] alone; what have we to do with thee, thou Jesus of Nazareth? art thou come to destroy us? I know thee who thou art, the Holy One of God.
Note 1 at Mr 1:24: The term "Holy One" is used forty-eight times in the Bible. Forty-two of those times are in the Old Testament, and all of these are clearly referring to Jehovah God (ex. Isa 30:15, 43:3, 14-15, 54:5; and Eze 39:7). David applied the term "Holy One" to the Messiah (Ps 16:10), as we can see by Peter's explanation on the Day of Pentecost (Ac 2:25-32). So Jesus being referred to as the "Holy One" is another clear reference to His divinity.
With this in mind, it might appear that this unclean spirit met the requirement of 1Jo 4:1-3 of confessing that Jesus Christ (see note 2 at Mt 16:16) was come in the flesh and thus was of God. However, the Scriptures make it clear that this was an unclean, or evil, spirit.
The Greek word translated "confesseth" in 1Jo 4:2 is "HOMOLOGEO," and it is the same word that is used in Ro 10:9-10 to confess salvation. By comparing scriptures, God's Word makes it clear that it takes more than just speaking the words "Jesus is my Lord" to produce the new birth. In Lu 6:46 Jesus said, "And why call ye me, Lord, Lord, and do not the things which I say?"
In Jas 2:19-20 James said, "Thou believest that there is one God; thou doest well: the devils also believe, and tremble. But wilt thou know, O vain man, that faith without works is dead?"
Consequently, just because spirits confess that Jesus is the Christ or the "Holy One of God" does not mean those spirits are of God because they spoke the words. You have to try the spirits by beholding the lifestyles of those individuals. It is a grave mistake to accept spirits as being of God simply because they repeat some words, when their actions are constantly in opposition to God (1Jo 3:7 and 10).