Added error checking for argument types and fixing tests