unit tests added and usage of paginate simplified