Keep fiddling with it.
After about the third go around, reinstalling the cap gets pretty routine.
Do not use force however. If you think maybe it is broken, look on eBay as you may find some pictures of it, or go to the parts dept of your dealer and ask them to look at it. The odds are it is OK, just takes time to figure out.
Also removing the cap is real easy as well once you know how.
With the cap removed it was good that you exercised the lock.
I always roll the drivers window down first and then try manually locking and unlocking the door. I do that about twice a year to make certain that the manual unlock has not frozen up. When you need it is not the time to find out it is frozen from lack of use.