[test_addr] add mocking & fix constness

Also fix a probable memory leak in tests & a segfault