added tests, helper method, and changed views to refactor code