Tests of fundamental physics with gravitational waves: Theory and application