add equality test and from_* functions