finalised layout of functions; began rewriting unit tests