Adding unit tests + bug fixes + binary file detection