added junit tests and minor fixes in IRGen