Buggery was a capital offence between 15 under UK law, although it rarely resulted in a death sentence. Importuning was an offer of sexual gratification between men, often for money. The Sexual Offences Act 1967 permitted sex between consenting men over 21 years of age when conducted in private, but the act specifically excluded public lavatories from being 'private'.
The Sexual Offences Act 2003 replaced this aspect with the offence of 'Sexual activity in a public lavatory' which includes solo masturbation.