adds before and after fn options for tests

Added tests and some doc.