fix test code segfaults due to n = 0