I thought tax avoidance (as in tax efficiency) was legal, it's tax evasion that not.
This is true but increasingly the Revenue will take a view on whether or not any action was taken specifically to avoid tax. If their view is there has been deliberate tax avoidance HMRC can, I understand, challenge the action.
For example my wife and I changed the ownership of our house from Joint Tennants to Tennants in Common. The first means the property is owned entirely and equally by both parties and automatically passes on at death. Joint Tennants each own a percentage of the property, in our case 50%, and we can individually decide who our heirs will be. On first death 50% of the property passes into trust for our son. The surviving partner receives nothing from the property. Importantly the survivor cannot be forced to leave the property.
We did this to help secure our disabled son's future on our deaths. One by product of this process is there cannot be a forced sale of the property.
We took this decision ten or more years ago. It's clear what our intentions were. If this was done a few weeks before death of a spouse with a known terminal condition HMRC would probably take the view there was some form of tax avoidance intended. If this was the case HMRC might challenge the action on the basis tax avoidance was the only purpose for the decision.