Fixed functions and added testing code