Added retain method.
Fixed unit tests.