fixed bug, added test and makefile