RX/TX not working as intended
You are using a Leonardo. Pins 0/1 aren't Serial, they're Serial1.  Serial is the built-in USB connection.

void setup() {
  Serial1.begin(9600);
}

void loop() {
   Serial1.print("test");
   Serial1.print("\n");

}