Section 39D. Such a town may enter upon any lands for the purpose of making surveys, test pits and borings, and may take or otherwise acquire the right to occupy temporarily any lands necessary for the construction of any work or for any other purpose authorized by said sections thirty-nine A to thirty-nine E, inclusive.