Councils lose challenge over houses in multiple occupation