refactoring and add tests for isValidOpenOrder