I believe God knew Abraham would pass the test though it was really tough. God never intended for Abraham to kill his son, Isaac. God tests us so that WE, not God, may know whether we truly fear or/and love God and grow in faith and love relationship with God. However, Satan confuses us with doubts and human thoughts so that we may not see God's good intention and providence. Through trials, Satan tempts us while God tests us.
My wife and I lost our second child at five month gestation. However this incident brought us closer to God who controls our life. Above all, I was more grateful than ever before to God for giving us eternal life through Jesus Christ.