Personally I do believe Tom knew that Michael was going to have Fredo killed. When Michael comes back from Havana he asks Tom about Fredo and Tom avoids the question. That tells me that Tom knows Michael better than to believe he is only asking out of concern. Tom knows that Michael would never allow an act of betrayal to go by, no matter if it was Fredo, Carlo, etc. However I do believe that Tom was uneasy about the decision even if he knew it was the right one.
As far as Michael treating Tom badly. I don't think he was treating him badly when he told him he was out. He was blunt about the situation, but that's just Michael. Don Vito let him know that he never thought he was a bad consigliere. Michael wanted Tom to stay out of the business so he would have somone to trust as the others have mentioned. I also think Michael didn't want to risk losing Tom, hence kept him on the legit side of things for awhile.
In the end of the film when Michael questions Tom's loyalty; I believe that was just Michael being paranoid. His wife had just had an abortion w/o his knowledge and his own brother had betrayed him. I think that scene was put in to show that Michael was kinda losing it, questioning everyone he loved because everyone he had loved, had hurt him in one way or another.
Also it's been said that Al Neri was trying to take Tom's place, so he could have been feeding Michael information to place him in an unfavorable light.
Tom Hagen has always been my favorite Godfather character. He was a voice of reason and his absence in Godfather III makes me cringe.