For all that has supposedly changed for Joseph, it seems he still is holding onto bitterness. Maybe he was testing his brothers to see if they had really felt sorry and repented of what they did to Joseph. Was he making sure they would protect his younger brother and do whatever they could to spare his life and make sure he returned safely to their father.
In the end, he tells them who he is and also lets them know not to feel bad for what they did because everything was in God's plan for him to be there. So even in Joseph's bitterness and resentment, he recognized that he was in God's plan for him. And it is important to see that he let go of that bitterness and graciously welcomed his brothers and their families to Egypt so that he could take care of them.