Add unit tests for allocate_field().