Re-factored testing code