fix pointer error - with unit tests