fixed allocation of last elements + rename classes + add tests