add tests and fix issue on --debug option