Add test for detaching models