fix bugs and setup test environment

1. setup test environment using karma
2. write 6 test cases to ensure correction
3. fix `displayName` bug
4. prevent throwing invariant error after we update the initial structure of this.state