Improved testing code structure