Add more test cases and fix bug with dryrun option