minor fixes and improve tests