add controller tests

add controller tests and fix issues found.