Fixed write_cas by adding session::clone()