Added unit tests and reworked equalities slightly