fix typing of ^ operator and add a test