Assert output in controller test. Also some refactorings.