fixed wrongly setting undefined value
added auto-drain emission feature
added basic attachment test