write more tests and fixed bugs for view