Add initial and last functions and tests