Fix testing procedure and fix tests