cleaned up some functions
adding some tests