Fix testing bins with lib deps

If a package had both bin and lib deps, `cargo test` was not building the `lib`
dependency when building the bins with `--test`. This commit adds an extra
"test" profile (not compiled with --test) for situations such as this which is
filtered out normally but kept around for the `cargo test` case.
Fix --release not compiling upstream deps with -O3

This touches up the filtering logic to ensure that upstream dependencies as well
as local dependencies are built with optimizations when `cargo build --release`
is used.
auto merge of #155 : alexcrichton/cargo/some-bugs, r=wycats

Details in the commits.