findFragmentById always returns null

Use the <FrameLayout> tag as a container in your layout file. Later to replace the fragments from your activity dynamically, you can use the ID of the <FrameLayout> container to replace the fragments in your activity.

<FrameLayout
            android:id="@+id/test_fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

R.id.test_fragment is not the ID of your fragment but the id of your LinearLayout

Calling add(int containerViewId, Fragment fragment) will add a fragment without a tag. So or you use add(int containerViewId, Fragment fragment, String tag) and you get back your fragment using your tag (as an ID)