Moved foldM into object and added a test case for empty list coming in