Added test suite

and fixed a couple of things