some bug but got a reasonable test working
All tests now pass