Refactor state module to reduce duplication
Bad args fix
Fix failing tests
Fix missing queue args
Merge pull request #13844 from cachedout/state_module_refactor

Refactor state module to reduce duplication