Tests for adding file reference + slight refactor