fix for filtering unwanted directories

* extracted subdir filter option to a function and add a failing test
* addd a fix for filtering unwanted dirs