Improve tests + minor fixes