Sorry, it took me so long to respond to this, I got caught-up in lot of stuff, and am still going through a lot of turmoil right now.
In regards to Jesus knowing whether or not he was divine, well, the Traditional Catholic view of humanity teaches that the human person is made up components, the mind, the will, and the body. Traditional Christology teaches that, at the incarnation, Christ's mind and will, were instantly fused with His divinity, while his body took a longer time to divinize, as God doesn't have a body. So intellectually Jesus did know that He was God. But neurologically, that's where things get murky, we're not sure how much of that knowledge, manifested in His brain. It should also be noted that, in the Old Testament, God would often feign ignorance, such as asking Cain what happened to Abel, when He, being omniscient, knew that Cain murdered Abel.
In regards to the issue of calling the gentile woman a "dog" there are a few explanations as to why He acted the way He did:
The first and most simple explanation is, that He is leaving out whole truth, and only telling part of it. Telling only part of the truth, is legitimate thing to do in certain situations, take for example, St. Athanasius fleeing a mob of Arians in a boat. St. Athanasius was once in a row boat fleeing the Arians when a group searching for him, came up to him and asked if he's seen him. St. Athanasius responds by saying, "yes, if you hurry you might catch him!" Thus he escapes the Arians without lying. In regards to Jesus' case here, Our Lord affirms the fact, that the gentile woman is a "dog" but what He's leaving out of that statement, is the truth that, we're all dogs, we're all sinful and fallen, (which in a sense, means that we're all sub-human) and need a Saviour.
A second possible explanation is, when this episode takes place, the Old Covenant is still in effect. Our Lord had to be circumcised and a Our Lady had to offer purification offerings, even though both were sinless, the reason they had to do this, was because the old law was still in effect, and it would be, up until the Crucifixion of Our Lord. The reason Our Lord called the Syro-Phoenician woman a "dog" had something to do with the Old Law, and the fact that gentiles had to be second-class citizens in the Old Covenant.
In either case, Our Lord was testing the faith of the Syro-Phoenician woman, He was seeing, how much the gentile was willing to take, in order to believe in Him.