improve unittest and fix some issues by unittest

- mainly fix validation