fix and improve tests