fix define dynamic method
add tests
cli handle error