Fix make check issue on out-of-tree builds and test it (#672)

4 files changed