refactor test_views from test_api