test flag calculation