Implement new test function using mock code.

Add int/long/ptr to mock code. Fix free()s.