refactor tests to table-driven tests