simplify test_function code