Fix encryption tests

cc @schiesbn 

port from #10458