Add tests and docs for padding
Handle both new and old mode for generating codes