add controller spec and refactors