Stability of variable-step BDF2 and BDF3 methods