Fix lcstate issues and add test
Fix lcstate issues and add test