Added head/tail interface and tests