fix demo, improve test coverage