added test and refactored Array.last if valid number is passed