added testing files and fixed bugs
cleaned up code