Fix optarg handling for listtransactions and add tests.