Some demo and test improvements
Add validity checking