Add test case; refactor