using test-framework and fixed various bugs as a result