On B-algebras and quasigroups