TokenEncoder implementation + UTs