Fixed bugs with moduleSelector, wrote tests for moduleSelector