Added controller unit tests and fixed bugs in controllers