It depends on if you define "Test cricketer" as best measurable and tangible output on a cricket pitch, or if you include captaincy and leadership into that mix.
With the latter, Imran is easily top 5. On talent, his sides had no business drawing two series against the West Indies, and to me he gets an incredible amount of credit for doing that, and also he was very good at utilizing overall team bowling talent, despite himself being a bowler, something which a certain current Australian captain might tell you, is no easy task. Of all post war all time great cricketers, he is easily my first choice for captain. (Miandad also for one of the ATG vice-captains as well).
If you are only including individual output as a batsman / bowler, then actually doing the math, it's not as easy as it appears to put Imran in the top 5. To me, Imran is the greatest all-rounder of all time ( although I rate all-rounders who are genuine front line bowlers ahead of other all-rounders, so I might have a different criteria than most ). This is great for a first pick in an all-time no Bradman draft, but I still don't rate him as a greater cricketer than Sobers. In addition, I don't rate his bowling quite as high as many others do. I'd put him with Warne and Wasim in the roughly 10-13 greatest modern bowlers. So for me I find I have to pick some players who are more superlative in their primary skill above him.
Bradman is a shoe-in, so you've only got 4 more slots to play with. McGrath and Sobers are also easily above Imran for impact in their primary discipline, in my opinion. Then there are a bunch of players who it's really hard to compare with. Guys like Murali, Weekes, etc. You could reasonably place one or both of them above Imran but you're making strange judgement calls in picking one definitively over another. Push comes to shove though, I'm putting them both over Imran, so suddenly Imran is out of my top 5. After that, I do definitely place him among the top 10, with guys like Lara, Hadlee, and Gavaskar but yeah, this is no straightforward exercise.
Also, you'll notice the exclusion of any pre WWII players in my conversation. To me, I don't really know the game from then, and can only really conjecture from the footage, so other than Bradman I don't really include them in many of these kinds of choices. But there are others who are not so reticent. I imagine for them there are even more worthy candidates, who keep Imran out of the top 5. So this isn't such a crazy consensus to be bucking, by not including him in there.
TLDR: Imran is the greatest Pakistani cricketer, and one of the closest to my heart that I am most grateful for. Objective analysis always makes things more complicated and less straightforward though.