Check before I update my iPhone 3gs to OS4

I am tired of trying to install apps and being told I need OS 4 so I am ready to take the plunge and update. I have put it off because my carrier is T Mobile so I need it to stay unlocked. I couldn't care less about jailbreaking but it appears I have to jailbreak to unlock. Fine.

So what is the newest firmware I can update to and still be unlocked? It seems from here to be 4.0.2 unless I want to update my baseband to 6.15.00 which is actually the baseband for the iPad. I would to that but it seems that sometimes wifi doesn't work after the update and I would like to have wifi so I would like to put that off.

Am I understanding all this correctly?