You can take the Life in UK Test whenever you want. Also as many times as you need (just a question of budget)
As others have said better to secure that pass certificate as early as possible and at a time that suits you. Leaving it too late will pile on the time pressures and may cause you to ultimately put off the ILR application.
The pass certificate has no expiry and there's no requirement for it to be recently issued at all.
Do what suits you best and fits in with your life now.
These are true life impacting issues.