Hysteresis and upscaling in two-phase flow through porous media