refactored controller for better testing, updated test case