Added first. last. random functions with proper tests