added most of precondition and expectation checking
added return value when opts$pure is true