simplified code, by adding tests

small changes to allow tests to be run, and therefore refactor the code.
added hashcode/equals for Asserts to work
simplified main application