added encapsulation example and tests