Better Makefile
Better validity check, add unit tests