added test and function definitions (missing implementations)