formatAsHours method with tests