Added tests and fixed bug found during testing