added junit and resolved minor bugs