[fix bug 1042552] moving logic to inside the view
[fix bug 1042552] unit tests