Fix unreferenced variable warnings

Fix warnings with void cast. Leave variables in the tests for making
sure that the mem leak checker does not detect local variables as a
memory leak.