fix tests, add flag checking