Added some test and fixed bug in ApplicationController