Added tests, improved functions, work in progress