Added tests and fixed a couple of bugs