Set initial currentPage starting point to 1 and fixed code affected, refactored out getMaxPages function, firing events when state changes and fixed and added new unit tests