Fixed old testing code and added trycatch