Refactor tests/Makefile.am to support more options