On the soliton dynamics under a slowly varying medium for generalized KdV equations