Fixed bug in equals and added unit test