Fix integer handling when encoding configuration

This PR fixes #1812.  Includes API tests and integration tests for the regression.