Some unit tests added, bugs with AGAP corrected