ENH: Improvements to `pad` and test suite backported from NumPy