Mr Bailey was accused of failing to pay £27,000 capital gains tax and penalties relating to a home he sold in Farnham, Surrey, in 2010.

The plan was to make the house a family home as he and his wife and children lived in separate properties.

Mr Bailey lived in the house for two short periods of eight to 10 weeks or so over two years.

HMRC argued he did not live in the property as his main home, so no tax relief was due on the sale.

The First Tier Tribunal disagreed and granted Mr Bailey main residence relief for the entire time he owned the home.

“I found Mr Bailey a straightforward witness and his evidence credible,” said the judge, Marilyn McKeever.

“I am satisfied that one each occasion when Mr Bailey moved into Richmond, he intended that his residence would be on a permanent basis and that the property would be his home.”

The residence test was set in Goodwin v Curtis (1998), which decided the quality of occupation rather than the length of time someone lived in a home was which counted the most. The taxpayer lost the case based on just 35 days of occupation.