Refactored setting of autoincrement information, with unit test