refactor demo and tests
performance changes