Fixes a padding work like python.
More comprehensive tests based on actual Python behavior