adds test for weak pointers
more correct code