"In the end he was always a loyal servant of the Lannisters..."
I disagree. Pycelle never showed absolute loyalty to the Lannisters. This was made abundantly clear all the way back at Joffrey's wedding. Cersei tells Pycelle to give the leftover wedding food which Queen Margery decreed was for the poor, to the dogs. Pycelle promptly tries to refuse since it would undermine the new queen's orders (Cersei then tells him that she is the queen and that she'll feed him to the dogs if he doesn't.)
Margery had literally just become Queen, and Pycelle was already shifting his loyalties. Pycelle is a pragmatist, not a loyalist.
It's worth noting that Pycelle also "faithfully" served the Targaryen dynasty for decades, until they fell out of power, at which point he betrayed them. Tommen was the 6th king Pycelle served under. He never would've survived so many power shifts if his loyalties weren't flexible.
In Cersei's eyes, Pycelle was a weed that needed to be pulled. And despite her frequent lack of foresight, she clearly understands the cardinal rule of the Game of Thrones: dead men can't plot against you.