split view.js, rewrite testcase in view_test.js