fix leaking global variables
tests: add passing test for file model.