Refactor table and test