Added options to specify output directory if needed. Tests modified accordingly.