added junit tests, fixed compile errors