Unit tests added, controller logic modified