Refactor test_value