added testing framework and fixed more minor bugs