Fix testing exceptions on python 3