JC: fixed bugs which cause spec fails in controller.