Added tests and fixed bug found when adding tests