added jUnit
refactored the two classes
added unit tests