tests: Add stack trace

With assert inside functions, it was difficult to trace errors, since
there was no way to tell where a function was called from.
This commit adds get_stack and print_stack functions which display
the call stack with the file and the line where the function was called
from along with the arguments.